---
title: Sensors
description: A library that provides access to a device's accelerometer, barometer, motion, gyroscope, light, magnetometer, and pedometer.
sourceCodeUrl: 'https://github.com/expo/expo/tree/main/packages/expo-sensors'
packageName: 'expo-sensors'
iconUrl: '/static/images/packages/expo-sensors.png'
platforms: ['android', 'ios', 'web']
---

import { Speedometer04Icon } from '@expo/styleguide-icons/outline/Speedometer04Icon';

import { APIInstallSection } from '~/components/plugins/InstallSection';
import { AndroidPermissions, IOSPermissions } from '~/components/plugins/permissions';
import { BoxLink } from '~/ui/components/BoxLink';
import {
  ConfigReactNative,
  ConfigPluginExample,
  ConfigPluginProperties,
} from '~/ui/components/ConfigSection';

`expo-sensors` provide various APIs for accessing device sensors to measure motion, orientation, pressure, magnetic fields, ambient light, and step count.

## Installation

<APIInstallSection />

## Configuration in app config

You can configure `expo-sensors` using its built-in [config plugin](/config-plugins/introduction/) if you use config plugins in your project ([Continuous Native Generation (CNG)](/workflow/continuous-native-generation/)). The plugin allows you to configure various properties that cannot be set at runtime and require building a new app binary to take effect. If your app does **not** use CNG, then you'll need to manually configure the library.

<ConfigPluginExample>

```json app.json
{
  "expo": {
    "plugins": [
      [
        "expo-sensors",
        {
          "motionPermission": "Allow $(PRODUCT_NAME) to access your device motion"
        }
      ]
    ]
  }
}
```

</ConfigPluginExample>

<ConfigPluginProperties
  properties={[
    {
      name: 'motionPermission',
      platform: 'ios',
      description:
        'A string to set the [`NSMotionUsageDescription`](#permission-nsmotionusagedescription) permission message or `false` to disable motion permissions.',
      default: '"Allow $(PRODUCT_NAME) to access your device motion"',
    },
  ]}
/>

## API

```js
import * as Sensors from 'expo-sensors';
// OR
import {
  Accelerometer,
  Barometer,
  DeviceMotion,
  Gyroscope,
  LightSensor,
  Magnetometer,
  MagnetometerUncalibrated,
  Pedometer,
} from 'expo-sensors';
```

## Permissions

### Android

Starting in Android 12 (API level 31), the system has a 200Hz limit for each sensor updates.

If you need an update interval greater than 200Hz, you must add the following permissions to your **app.json** inside the [`expo.android.permissions`](../config/app/#permissions) array.

<AndroidPermissions permissions={['HIGH_SAMPLING_RATE_SENSORS']} />

<ConfigReactNative>

If you're not using Continuous Native Generation ([CNG](/workflow/continuous-native-generation/)) or you're using native **android** project manually, add `HIGH_SAMPLING_RATE_SENSORS` permission to your project's **android/app/src/main/AndroidManifest.xml**:

```xml
<uses-permission android:name="android.permission.HIGH_SAMPLING_RATE_SENSORS" />
```

</ConfigReactNative>

### iOS

The following usage description keys are used by this library:

<IOSPermissions permissions={['NSMotionUsageDescription']} />

## Available sensors

For more information, see the documentation for the sensor you are interested in:

<BoxLink
  title="Accelerometer"
  href="accelerometer"
  description="Measures device acceleration on all platforms."
  Icon={Speedometer04Icon}
/>
<BoxLink
  title="Barometer"
  href="barometer"
  description="Measures pressure on Android and iOS platforms."
  Icon={Speedometer04Icon}
/>
<BoxLink
  title="DeviceMotion"
  href="devicemotion"
  description="Measures device motion on all platforms."
  Icon={Speedometer04Icon}
/>
<BoxLink
  title="Gyroscope"
  href="gyroscope"
  description="Measures device rotation on all platforms."
  Icon={Speedometer04Icon}
/>
<BoxLink
  title="Magnetometer"
  href="magnetometer"
  description="Measures magnetic fields on Android and iOS platforms."
  Icon={Speedometer04Icon}
/>
<BoxLink
  title="LightSensor"
  href="light-sensor"
  description="Measures ambient light on Android platform."
  Icon={Speedometer04Icon}
/>
<BoxLink
  title="Pedometer"
  href="pedometer"
  description="Measures steps count on Android and iOS platforms."
  Icon={Speedometer04Icon}
/>
